<?php

namespace app\common\model;

/**
 * [OrderComment  订单评论表]
 * @author [C。]
 * @return html
 */
class OrderComment extends Base
{
    protected $name = 'order_comment';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getList($map,$from = 0, $size = 5,$field='*')
    {
        $order = ['c.id' => 'desc'];
        $join1 = [
            ['app_order o','o.id = c.orderid'],
        ];
        $join2 = [
            ['app_member m','m.id = c.memid'],
        ];
        $join3 = [
            ['app_goods_option g','g.id = o.optionid'],
        ];
        $result = $this->field($field)
            ->alias('c')
            ->join($join1)
            ->join($join2)
            ->join($join3)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }
    /**
     * 根据搜索条件获取总条数
     */
    public function getCount($map)
    {
        $join1 = [
            ['app_order o','o.id = c.orderid'],
        ];
        $join2 = [
            ['app_member m','m.id = c.memid'],
        ];
        $join3 = [
            ['app_goods_option g','g.id = o.optionid'],
        ];
        $result = $this
            ->alias('c')
            ->join($join1)
            ->join($join2)
            ->join($join3)
            ->where($map)
            ->count();

        return $result;
    }
    /**
     * 根据搜索条件获取列表信息
     */
    public function getAllSum($map,$field)
    {
        $join = [
            ['app_order o','o.id = c.orderid'],
        ];

        $result = $this->alias('c')
            ->join($join)
            ->where($map)
            ->sum($field);

        return $result;
    }
    /**
     * 根据搜索条件获取列表信息
     */
    public function getAllCounts($map)
    {
        $join = [
            ['app_order o','o.id = c.orderid'],
        ];

        $result = $this->alias('c')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
}